{% extends "base.html" %}

{% block extrajs %}
<script type="text/javascript">
    var MENU_CAN_HIDE = false;
    dojo.addOnLoad(function() { 
        dojo.style("gauche", "display", "block"); 
        dojo.style("menuPrincipal", "paddingLeft", "210px"); 
        dojo.style("contenu", "marginLeft", "210px"); 
    });
</script>

<!-- Graphing -->
<script src="{{ MEDIA_URL }}js/jquery-1.5.min.js" type="text/javascript"></script>
<script src="{{ MEDIA_URL }}js/highcharts.js" type="text/javascript"></script>
<script src="{{ MEDIA_URL }}js/themes/grid.js" type="text/javascript"></script>
<script src="{{ MEDIA_URL }}javascript/ticket/graph_opentickets.js" type="text/javascript"></script>
<script src="{{ MEDIA_URL }}javascript/ticket/graph_recall.js" type="text/javascript"></script>
<!-- End Graphing -->

{% endblock %}

{% block content %}
{% if not user.is_authenticated %}
<p style="margin-bottom: 0;">Merci de vous <a href="/accounts/login/">IDENTIFIER</a></p>
<h1 style="text-align: left; color: black; padding: 0; margin: 0;">Rechercher sur Google:</h1>
<!-- Google search -->
<div id="cse" style="text-align: left; padding: 0 !important;">Chargement...</div>
<script src="https://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
  google.load('search', '1', {language : 'fr'});
  google.setOnLoadCallback(function() {
    var customSearchControl = new google.search.CustomSearchControl('016334670055041449914:jgrecjhkx1o');
    customSearchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
    customSearchControl.draw('cse');
  }, true);
</script>
<link rel="stylesheet" href="https://www.google.com/cse/style/look/default.css" type="text/css" /> 
<!-- End Google search -->

{% else %}
<div id="index_content">
    {% if ticket_alarms %}
    <div class="container">
        <h2>Alarmes</h2>
        <ul>
          {% for ticket in ticket_alarms %}
            <li><a href="{% url ticket_modify ticket.pk %}">[{{ ticket.id }}] {{ ticket.title|truncatewords:8 }}</a></li>
          {% endfor %}
        </ul>
    </div>
    {% endif %}
    {% if ticket_dashboard_critical %}
    <div id="list_critical_tickets" class="container" style="width: 500px;" >
        <h2>Tickets critiques</h2>
        <ul>
          {% for ticket in ticket_dashboard_critical %}
            <li><a href="{% url ticket_modify ticket.pk %}">[{{ ticket.id }}] {{ ticket.title|truncatewords:8 }}</a></li>
          {% endfor %}
        </ul>
    </div>
    {% endif %}
    
    {% if ticket_dashboard_text_statistics %}
    <div id="list_stats" class="container">
        <h2>Statistiques</h2>
        <ul>
          {% for entry in ticket_dashboard_text_statistics %}
            <li>{{ entry }}</li>
          {% endfor %}
        </ul>
    </div>
    {% endif %}
    <div id="stats_graph" class="container" style="width: 700px; height: auto;">
        <script type="text/javascript">
        dojo.addOnLoad(function() {
            var options;
            options = graph_opentickets_init('graph_opentickets', 31);
            graph_opentickets_load(options, '{% url ajax_graph_opentickets %}', 'month');
        });
        dojo.addOnLoad(function() {
            options = graph_recall_init('graph_recall', 7);
            graph_recall_load(options, '{% url ajax_graph_recall %}', 'weeks');
        });
        </script>
        <h2>Graphiques</h2>
        <div id="graph_opentickets"></div>
        <div id="graph_recall"></div>
    </div>
</div>
{% endif %}

{% endblock %}
